function land() {
    axios.get("/user/land",{
        params:{
            username:$("username").value,
            pwd:$("pwd").value
        }
    }).then( resp => {
        let info = resp.data;
        if (info == "ok"){
            location.href = "/index.html"
        }
        else {
            $("errorSpan").innerHTML = "登陆失败"
        }
    });
}

function changeFace() {
    var reader = new FileReader();//定义文件读取流对象
    reader.readAsDataURL($("fileText").files[0]);
    reader.onload = function (ev) {
        $("faceImg").src = ev.target.result;
    }
}

async function register() {
    let formObj = new FormData();
    formObj.append("uploadImg",$("fileText").files[0])

    let config = {
        headers: {'Content-Type': 'multipart/form-data' }
    }

    let uploadFilename;
    await axios.post("/upload",formObj,config).then(resp => {
        uploadFilename = resp.data;
    });

    axios.get("/user/add",{
        params:{
            username:$("usernameText").value,
            pwd:$("pwdText").value,
            imgPath:uploadFilename,
            email:$("emailText").value,
            nickname:$("nicknameText").value
        }
    }).then(resp => {
        let info = resp.data;
        if (info == "ok"){
            $("registered").style.visibility = "hidden";
        }
    });
}




















/**
 * 注册按钮点击事件
 */
function showRegister() {
    if ($("registered").style.visibility == "hidden") {
        $("registered").style.visibility = "visible";
    }
    else {
        $("registered").style.visibility = "hidden";
    }
}

/**
 * 返回按钮点击事件
 */
function closeRegistered() {
    if ($("registered").style.visibility == "visible") {
        $("registered").style.visibility = "hidden";
    }
    else {
        $("registered").style.visibility = "visible";
    }
}